package net.sipvip.server;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Users {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private String cookies;
	@Persistent
	private String ipstr;
	@Persistent
	private Date create_date;
	@Persistent
	private Date update_date;
	@Persistent
	private String city;
	@Persistent
	private String country;
	@Persistent
	private int visit_counter;

	public Users(String create_date, String update_date) {
		Date today = null;
		DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
		try {
			today = df.parse(create_date);

		} catch (ParseException e) {
			e.printStackTrace();
		}
		this.create_date = today;

		try {
			today = df.parse(update_date);

		} catch (ParseException e) {
			e.printStackTrace();
		}

		this.update_date = today;
	}

	public Users(String cookies, String ipstr, String create_date, String update_date,
			String city,String country, int visit_counter) {
		this(create_date, update_date);
		this.cookies = cookies;
		this.ipstr = ipstr;
		this.city = city;
		this.country = country;
		this.visit_counter =visit_counter;  
	}

	public Long getId() {
		return this.id;
	}

	public String getCookies() {
		return this.cookies;
	}

	public void setCookies(String cookies) {
		this.cookies = cookies;
	}

	public String getIpstr() {
		return this.ipstr;
	}

	public void setIpstr(String ipstr) {
		this.ipstr = ipstr;
	}

	public Date getCreate_date() {
		return this.create_date;
	}

	public void setCreate_date(Date create_date) {

		this. create_date= create_date;
	}

	public Date getUpdate_date() {
		return this.update_date;
	}

	public void setUpdae_date(Date update_date) {
		this.update_date = update_date;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public int getVisit_counter() {
		return visit_counter;
	}

	public void setVisit_counter(Integer visit_counter) {
		this.visit_counter = visit_counter;
	}
	
	
}

